import { allPaths } from './paths'
import request from '@/utils/request'
import common from '@/api/common'

export default {

  getArchiveInfoById (params, data) {
    const queryParams = {
      pageIndex: 1,
      pageSize: 10,
      configFile: 'dynamicsql/archive.xml',
      configName: 'getArchiveDetail'
    }
    Object.assign(queryParams, data)

    return request({
      url: allPaths.sql.pageQuery,
      method: 'post',
      params: params,
      data: queryParams
    })
  },

  getCreateProcessList (modelWidgetId, matterType, ignoreStartUser) {
    const params = {
      filterBusiness: true,
      modelWidgetId,
      businessAsGroup: true,
      matterType: matterType,
      ignoreStartUser: ignoreStartUser || false
    }

    return request({
      url: allPaths.project.getCreateProcessList,
      method: 'get',
      params: params
    })
  },

  getCreateProcessListByBusinessName (businessName) {
    const params = {
      filterBusiness: true,
      businessAsGroup: true,
      businessName: businessName,
      ignoreStartUser: false
    }

    return request({
      url: allPaths.project.getCreateProcessList,
      method: 'get',
      params: params
    })
  },

  getCreateProcessList1 (modelWidgetId, matterType, ignoreStartUser) {
    const params = {
      filterBusiness: true,
      modelWidgetId,
      businessAsGroup: false,
      matterType: matterType,
      ignoreStartUser: ignoreStartUser || false
    }

    return request({
      url: allPaths.project.getCreateProcessList,
      method: 'get',
      params: params
    })
  },

  readMessageItem (messageIds) {
    const params = {
      messageItemIds: messageIds
    }

    return request({
      url: allPaths.project.readMessageItem,
      method: 'post',
      params: params
    })
  },

  getNotReadMessageCount () {
    return request({
      url: allPaths.project.getNotReadMessageCount,
      method: 'get'
    })
  },
  getStartProcessTree (params) {
    console.log(allPaths.project.getCreateProcessList)
    return request({
      url: allPaths.project.getCreateProcessList,
      method: 'get',
      params: params
    })
  },
  startProject (params) {
    console.log(allPaths.project.startProject)
    return request({
      url: allPaths.project.startProject,
      method: 'post',
      data: params
    })
  },

  updateDkState (params) {
    console.log(allPaths.project.updateDkState)
    return request({
      url: allPaths.project.updateDkState,
      method: 'post',
      params: params
    })
  },

  sendCode (params) {
    return request({
      url: allPaths.project.sendCode,
      method: 'get',
      params: params
    })
  },
  getBizActDetailByActId (params) {
    // return request({
    //   url: allPaths.project.getBizActDetailByActId,
    //   method: 'get',
    //   params: params
    // })
    return common.get(allPaths.project.getBizActDetailByActId, params)
  },

  getBusinessItemMapById (params) {
    // console.log(allPaths.project.deleteBusinessItemMap)
    return request({
      url: allPaths.project.getBusinessItemMapById,
      method: 'get',
      params: params
    })
  },

  saveBusinessItemMap (params) {
    return request({
      url: allPaths.project.saveBusinessItemMap,
      method: 'post',
      data: params
    })
  },

  deleteBusinessItem (params) {
    // console.log(allPaths.project.deleteBusinessItemMap)
    return request({
      url: allPaths.project.deleteBusinessItem,
      method: 'post',
      params: params
    })
  },

  saveBusinessItemForm (params) {
    return request({
      url: allPaths.project.saveBusinessItemForm,
      method: 'post',
      data: params
    })
  },
  deleteBusinessItemForm (params) {
    // console.log(allPaths.project.deleteBusinessItemMap)
    return request({
      url: allPaths.project.deleteBusinessItemForm,
      method: 'post',
      params: params
    })
  },

  saveBusinessItemMaterial (params) {
    return request({
      url: allPaths.project.saveBusinessItemMaterial,
      method: 'post',
      data: params
    })
  },
  deleteBusinessItemMaterial (params) {
    return request({
      url: allPaths.project.deleteBusinessItemMaterial,
      method: 'post',
      params: params
    })
  },
  getBusinessItemMaterialMapById (id) {
    return request({
      url: allPaths.project.getBusinessItemMaterialMapById,
      method: 'get',
      params: { id }
    })
  },
  getAllInvestmentList (params) {
    return request({
      url: allPaths.project.getAllInvestmentList,
      method: 'get',
      params: params
    })
  },

  getBusinessItemMapList (param) {
    return request({
      url: allPaths.project.getBusinessItemList,
      method: 'get',
      params: param
    })
  },
  listBusinessItemBySource (source) {
    return request({
      url: allPaths.project.listBusinessItemBySource,
      method: 'get',
      params: { source }
    })
  },
  getInvestmentItemFormList (itemCode) {
    return common.get(allPaths.project.getInvestmentItemFormList, { itemCode: itemCode })
  },

  saveBusinessItemMaterialList (businessMaterialList) {
    return common.post(allPaths.project.saveBusinessItemMaterialList, null, businessMaterialList)
  },

  saveBusinessItemFormList (businessItemFormList) {
    return common.post(allPaths.project.saveBusinessItemFormList, null, businessItemFormList)
  },

  getBusinessItemFormMapById (id) {
    return common.get(allPaths.project.getBusinessItemFormMapById, { id })
  },

  getInvestmentItemFormListByType (InvestmentForm) {
    return common.get(allPaths.project.getInvestmentItemFormListByType, InvestmentForm, null)
  },
  getInvestmentItemFormListByTypeSource (InvestmentForm) {
    return common.get(allPaths.project.getInvestmentItemFormListByTypeSource, InvestmentForm, null)
  },
  listInvestmentItemFormListByTypeSource (params) {
    return common.get(allPaths.project.listInvestmentItemFormListByTypeSource, params, null)
  },

  updateMaterialIndex (data) {
    return request({
      url: allPaths.project.updateMaterialIndex,
      method: 'post',
      params: data
    })
  }

}
